package cn.dust.design.pattern.behavioral.iterator;

import java.util.List;

/**
 * @Author: dust
 * @Date: 2019/11/27 18:46
 */
public class CourseIteratorImpl implements CourseIterator{

    private List courseList;
    int position=0;
    Course course;

    public CourseIteratorImpl(List courseList) {
        this.courseList = courseList;
    }

    @Override
    public Course nextCourse() {

        System.out.println("返回课程的位置:"+position);
        course= (Course) courseList.get(position);
        position++;
        return course;
    }

    @Override
    public boolean isLastCourse() {
        if(position<courseList.size()){
            return false;
        }
        return true;
    }
}
